# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import Union, List
from pydantic import BaseModel, Field
from fastapi import Query


class VideoConfigIn(BaseModel):
    engine: str = Query(..., pattern=r"^(luma|zhipu)$", description="视频引擎")


class VideoRecordSearchIn(BaseModel):
    """ 视频记录搜索参数 """
    page_no: int = Query(default=1, gt=0, description="当前页码")
    page_size: int = Query(default=15, gt=0, le=200, description="每页条数")
    engine: str = Query(..., pattern=r"^(luma|zhipu)$", description="视频引擎")
    status: Union[int, str, None] = Query(default=None, description="生成状态: [0=待生成, 1=生成中, 2=成功, 3=失败]")


class VideoRecordDetectionIn(BaseModel):
    """ 视频记录检测参数 """
    ids: List[str] = Field(default=[], description="记录编号")


class VideoRecordCodeIn(BaseModel):
    """ 视频记录编号参数 """
    code: str = Field(..., max_length=32, description="视频编号")


class VideoGenerateIn(BaseModel):
    """ 视频生成参数"""
    engine: str = Field(..., pattern=r"^(luma|zhipu)$", description="视频引擎")
    prompt: str = Field(..., min_length=1, max_length=5000, description="视频描述")
    scale: str = Field(..., max_length=50, description="视频比例")
    image_url: str = Field(default="", max_length=250, description="开始图片")
    other_params: dict = Field(default={}, description="其它参数")

    @classmethod
    def messages(cls):
        return {
            "prompt.min_length": "请填写视频描述词"
        }

    class Config:
        json_schema_extra = {
            "example": {
                "engine": "luma",
                "prompt": "视频描述",
                "scale": "1:1",
                "image_url": "参考图片",
                "other_params": {}
            }
        }


"""--------------- Separator ---------------"""


class VideoConfigVo(BaseModel):
    options: List[dict] = Field(description="应用选项")
    configs: dict = Field(description="配置参数")


class VideoRecordsVo(BaseModel):
    """ 视频记录列表Vo """
    engine: str = Field(description="视频引擎")
    code: str = Field(description="记录编号")
    type: str = Field(description="类型: [text2video, image2video]")
    scale: str = Field(description="视频比例")
    prompt: str = Field(description="提示词")
    image_url: str = Field(description="垫图地址")
    video_url: str = Field(description="视频地址")
    use_points: int = Field(description="消耗积分")
    is_free: int = Field(description="免费调用: [0=否, 1=是]")
    status: int = Field(description="生成状态: [0=等待中, 1=执行中, 2=成功, 3=失败]")
    share_status: int = Field(description="分享广场: [0=待审, 1=审核通过, 2=审核拒绝]")
    share_result: str = Field(description="分享结果")
    fail_reason: str = Field(description="失败原因")
    create_time: str = Field(description="创建时间")

    class Config:
        json_schema_extra = {
            "example": {

            }
        }
